<template>
  <div>
    <a-spin :spinning="spinning !== 0">
      <!-- 头部插槽 -->
      <component
        ref="header"
        v-if="header.show"
        :is="header.componentFile"
        :stores="stores"
      />

      <!-- 查询区域 -->
      <div class="table-page-search-wrapper" v-if="queryColumns.length > 0">
        <a-form layout="horizontal" @keyup.enter.native="searchQuery">
          <a-row :gutter="8">
            <a-col v-for="(query, index) in queryColumns" :key="query.colCode"
                   :span="query.queryFormatJson.compColSpan || 6"
                   v-if="query.queryIsHidden !== 'Y'">
              <a-form-item :label="$locale(query.queryAlias || query.colName)"
                           :labelCol="typeof query.queryFormatJson.labelColSpan !== 'undefined' ? {span: query.queryFormatJson.labelColSpan} : labelCol"
                           :wrapperCol="typeof query.queryFormatJson.wrapperColSpan !== 'undefined' ? {span: query.queryFormatJson.wrapperColSpan} : wrapperCol">
                <view-select-tag
                  v-if="query.showType === 'page'"
                  :placeholder="$locale(query.queryFormatJson.placeholder || query.queryAlias || query.colName)"
                  v-model="query.queryDefaultValue"
                  :viewCode="query.queryFormatJson.viewCode"
                  :keyField="query.queryFormatJson.keyField"
                  :labelField="query.queryFormatJson.labelField"
                  :multi="query.queryFormatJson.multiple"
                />
                <query-field v-else
                             :placeholder="$locale(query.queryFormatJson.placeholder || query.queryAlias || query.colName)"
                             v-model.trim="query.queryDefaultValue"
                             :type="query.showType"
                             :linkageMap="linkageMap"
                             @setLinkageMap="changeQueryField(query, $event)"
                             :showConfig="query.queryFormatJson"
                             :dictOptions="dictOptions" :dictOptionsFlg="dictOptionsFlg"></query-field>
              </a-form-item>
            </a-col>
            <template v-if="toggleSearchStatus">
              <a-col v-for="(query, index) in queryColumns" :key="query.colCode"
                     :span="query.queryFormatJson.compColSpan || 6"
                     v-if="query.queryIsHidden === 'Y'">
                <a-form-item :label="$locale(query.queryAlias || query.colName)"
                             :labelCol="typeof query.queryFormatJson.labelColSpan !== 'undefined' ? {span: query.queryFormatJson.labelColSpan} : labelCol"
                             :wrapperCol="typeof query.queryFormatJson.wrapperColSpan !== 'undefined' ? {span: query.queryFormatJson.wrapperColSpan} : wrapperCol">
                  <view-select-tag
                    v-if="query.showType === 'page'"
                    :placeholder="$locale(query.queryFormatJson.placeholder || query.queryAlias || query.colName)"
                    v-model="query.queryDefaultValue"
                    :viewCode="query.queryFormatJson.viewCode"
                    :keyField="query.queryFormatJson.keyField"
                    :labelField="query.queryFormatJson.labelField"
                    :multi="query.queryFormatJson.multiple"
                  />
                  <query-field v-else
                               :placeholder="$locale(query.queryFormatJson.placeholder || query.queryAlias || query.colName)"
                               v-model.trim="query.queryDefaultValue"
                               :type="query.showType"
                               :linkageMap="linkageMap"
                               @setLinkageMap="changeQueryField(query, $event)"
                               :showConfig="query.queryFormatJson"
                               :dictOptions="dictOptions" :dictOptionsFlg="dictOptionsFlg"></query-field>
                </a-form-item>
              </a-col>
            </template>
            <a-col :span="6">
              <span style="margin-top: 4px;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">{{ $t('m.common.button.query') }}</a-button>
                <a-button type="default" @click="searchReset" icon="reload"
                          style="margin-left: 8px">{{ $t('m.common.button.reset') }}</a-button>
                <a @click="handleToggleSearch" style="margin-left: 8px" v-if="needToggleSearchStatus">
                  {{ toggleSearchStatus ? this.$t('m.common.button.fold') : this.$t('m.common.button.expand') }}
                  <ych-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
                </a>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <!-- 查询区域-END -->

      <div style="position: relative; top: -20px; float: right; height: 0;">
        <YchTableColSettings
          style="height: 16px; width: 16px;"
          :tableKey="viewCode"
          :initSettingColumns="originalColumns"
          @customColumnChange="customColumnChange"
        >
        </YchTableColSettings>
      </div>

      <!-- table区域-begin -->
      <vxe-table
        header-align="center"
        border
        :scroll-y="{enabled: false}"
        ref="xTable"
        class="sortable-row-vxe"
        keep-source
        show-overflow
        show-header-overflow
        :span-method="mergeRowMethod"
        :row-config="{isHover: true, useKey: true, keyField: 'id'}"
        :data="dataSource"
        :sort-config="{trigger: 'cell', orders: ['desc', 'asc', null]}"
        @sort-change="sortChangeEvent"
        @cell-click="clickCellEvent"
        :row-style="getRowStyle"
        :cell-style="getCellStyle"
        :seq-config="treeEnable ? undefined : {seqMethod}"
        :column-config="{resizable: true}"
        :checkbox-config="treeEnable ? {reserve: true, checkStrictly: true} : {reserve: true}"
        :radio-config="{reserve: true}"
        :tree-config="treeEnable ? {transform: true, rowField: 'id', parentField: treeParentField} : undefined"
        :edit-config="{trigger: 'click', mode: 'row', showUpdateStatus: true, showInsertStatus: true}">
        <vxe-column type="radio" :width="radioColumn.width" :fixed="radioColumn.fixed"
                    v-if="!multi"></vxe-column>
        <vxe-column type="checkbox" :width="checkboxColumn.width" :fixed="checkboxColumn.fixed"
                    v-if="multi"></vxe-column>
        <vxe-column type="seq" :title="columnLineNum.title" :width="treeEnable ? 120 : columnLineNum.width"
                    :align="treeEnable && treeNodeField === '_seq' ? 'left' : columnLineNum.align"
                    header-align="center"
                    :fixed="columnLineNum.fixed" :tree-node="treeEnable && treeNodeField === '_seq'"
                    v-if="columnLineNum.show"></vxe-column>

        <template v-for="(item, index) in columns">
          <vxe-colgroup
            v-if="item.children && item.children.length > 0"
            :title="item.title">
            <vxe-column
              v-for="(children) in item.children"
              :key="children.dataIndex"
              :field="children.dataIndex"
              :title="children.title"
              :min-width="children.minWidth"
              :width="children.width"
              :align="children.align"
              header-align="center"
              :show-overflow="typeof children.showOverflow !== 'undefined' ? children.showOverflow : undefined"
              :sortable="children.sorter"
              :tree-node="treeEnable && treeNodeField === children.dataIndex"
              :fixed="children.fixed">

              <template #default="{ row, column }" v-if="children.slotDefault">
                <ViewImageSlot v-if="children.slotDefault === 'image'" v-model="row[children.dataIndex]"/>
                <ViewFileSlot v-else-if="children.slotDefault === 'file'" v-model="row[children.dataIndex]"/>
                <a v-else-if="children.slotDefault === 'links'" :href="row[children.dataIndex]" target="_blank"
                   :title="row[children.dataIndex]">{{ row[children.dataIndex] }}</a>
                <a-switch v-else-if="children.slotDefault === 'switch'" :disabled="true"
                          :checked="row[children.dataIndex] === 'true'"/>
                <div v-else-if="children.slotDefault === 'html'" v-html="row[children.dataIndex]"></div>
              </template>

            </vxe-column>
          </vxe-colgroup>
          <vxe-column
            v-else
            :field="item.dataIndex"
            :title="item.title"
            :min-width="item.minWidth"
            :width="item.width"
            :align="item.align"
            header-align="center"
            :show-overflow="typeof item.showOverflow !== 'undefined' ? item.showOverflow : undefined"
            :sortable="item.sorter"
            :tree-node="treeEnable && treeNodeField === item.dataIndex"
            :fixed="item.fixed">

            <template #default="{ row, column }" v-if="item.slotDefault">
              <ViewImageSlot v-if="item.slotDefault === 'image'" v-model="row[item.dataIndex]"/>
              <ViewFileSlot v-else-if="item.slotDefault === 'file'" v-model="row[item.dataIndex]"/>
              <a v-else-if="item.slotDefault === 'links'" :href="row[item.dataIndex]" target="_blank"
                 :title="row[item.dataIndex]">{{ row[item.dataIndex] }}</a>
              <a-switch v-else-if="item.slotDefault === 'switch'" :disabled="true"
                        :checked="row[item.dataIndex] === 'true'"/>
              <div v-else-if="item.slotDefault === 'html'" v-html="row[item.dataIndex]"></div>
            </template>

          </vxe-column>

        </template>

      </vxe-table>
      <vxe-pager
        v-if="pagination.show"
        border
        size="small"
        :current-page="pagination.current"
        :page-size="pagination.pageSize"
        :total="pagination.total"
        :page-sizes="pagination.pageSizes"
        :layouts="pagination.layouts"
        @page-change="handlePageChange">
      </vxe-pager>

      <!-- 尾部插槽 -->
      <component
        ref="footer"
        v-if="footer.show"
        :is="footer.componentFile"
        :stores="stores"
      />
    </a-spin>
  </div>
</template>

<script>

import {getAction, deleteAction, putAction, postAction, httpAction, downFile} from '@/api/manage'
import QueryField from '../../select/tag/QueryField'
import {initDictOptionMap} from '@/components/dict/YchDictSelectUtil'
import ViewImageSlot from '../../redirect/ViewImageSlot'
import ViewFileSlot from '../../redirect/ViewFileSlot'
import YchConstant from "@/api/YchConstant";
import {handleCreateFunc, handleExecFunc} from '@/utils/actions'
import {elValue} from '../../ElValue'
import moment from 'moment'
import YchTableColSettings from '@/components/ych/YchTableColSettings'
import error from "../../../common/exception/404";

export default {
  name: 'ViewEditableSelectRedirect',
  components: {
    QueryField,
    ViewSelectTag: () => import('./ViewSelectTag'),
    ViewImageSlot,
    ViewFileSlot,
    YchTableColSettings,
  },
  props: {
    viewCode: String,
    multi: Boolean,
    rows: Array,
    keys: Array,
    fks: {
      type: Array,
      default: () => []
    },
    parameterValue: {
      type: Array,
      default: () => []
    },
    stores: {
      type: Object,
      default: () => {
        return {}
      }
    },
  },
  data() {
    return {
      header: {show: false},
      footer: {show: false},
      tableName: null,
      queryColumns: [],
      tableCols: [],
      columns: [],
      originalColumns: [],
      dictOptions: {},
      linkageMap: {},
      dictOptionsFlg: 0,
      radioColumn: {
        width: 50,
        fixed: null,
      },
      checkboxColumn: {
        width: 50,
        fixed: null,
      },
      columnLineNum: {
        show: false,
        title: this.$t('m.common.label.number'),
        width: 60,
        align: 'center',
        fixed: null,
      },
      dataSource: [],
      pagination: {
        show: true,
        current: 1,
        pageSize: 10,
        total: 0,
        pageSizeOptions: ['10', '20', '50', '100', '200', '500'],
        layouts: ['PrevPage', 'JumpNumber', 'NextPage', 'Sizes', 'Total'],
      },
      sorter: {},
      spinning: 0,
      toggleSearchStatus: false,
      needToggleSearchStatus: false,
      url: {
        getViewModel: YchConstant.PREFIX_EFORM + '/engine/viewEngine/getViewModel',
        queryViewListPage: YchConstant.PREFIX_EFORM + '/engine/viewEngine/queryViewListPage',
        queryViewList: YchConstant.PREFIX_EFORM + '/engine/viewEngine/queryViewList',
        removeData: YchConstant.PREFIX_EFORM + '/engine/viewEngine/removeDataByBoCode',
        exportXlsUrl: YchConstant.PREFIX_EFORM + '/engine/viewEngine/exportXls',
        getExcelMax: YchConstant.PREFIX_EFORM + '/engine/viewEngine/getExcelMax',
      },
      tableShow: {},
      labelCol: {
        span: 8
      },
      wrapperCol: {
        span: 16
      },
      treeEnable: false,
      treeNodeField: null,
      treeParentField: null,
    }
  },
  created() {
    this.spinning++
    getAction(this.url.getViewModel, {viewCode: this.viewCode}).then((res) => {
      if (res.success) {
        this.init(res.result)
      } else {
        this.messageUtil.warning(res.message)
      }
    }).finally(() => {
      this.spinning--
    })
  },
  methods: {
    customColumnChange(settingColumns) {
      this.columns = []
      this.$nextTick(() => {
        this.columns = settingColumns.filter(item => item.visible === true)
        this.$nextTick(() => {
          this.$refs.xTable.refreshColumn()
        })
      })
    },
    init(result) {
      const that = this
      this.tableShow = result.tableShow
      this.tableName = result.tableShow.tableName
      this.treeEnable = result.tableShow.treeEnable === 'Y'
      this.treeNodeField = result.tableShow.treeNodeField
      this.treeParentField = result.tableShow.treeParentField
      this.$emit("setDialogTitle", result.tableShow.dialogTitle)
      //查询条件
      this.queryColumns = result.queryShow || []

      let elValueValue = result.elValue
      this.queryColumns.forEach(query => {
        query.queryFormatJson = query.queryFormat ? JSON.parse(query.queryFormat) : {}

        if (query.queryFormatJson.dictOption && query.queryFormatJson.dictOption.dictCode) {
          that.dictOptions[query.queryFormatJson.dictOption.dictCode] = []
        }

        if (elValueValue && query.queryDefaultValue) {
          query.queryDefaultValue = elValue(elValueValue, query.queryDefaultValue)
          if (query.showType === 'date') {
            if (query.queryDefaultValue) {
              let mountDate = moment(query.queryDefaultValue, 'YYYY-MM-DD HH:mm:ss')
              let queryFormat = 'YYYY-MM-DD'
              if (query.queryFormatJson && query.queryFormatJson.format) {
                queryFormat = query.queryFormatJson.format
              }
              let mountStr = mountDate.format(queryFormat)
              mountStr = moment(mountStr, queryFormat).format('YYYY-MM-DD HH:mm:ss')
              query.queryDefaultValue = mountStr
            }
          }
        }
      })
      this.needToggleSearchStatus = this.queryColumns.filter(vo => vo.queryIsHidden === 'Y').length > 0
      //行号
      if (result.tableShow.isLineNum === 'Y') {
        this.columnLineNum.show = true
      }
      // 临时变量，判断有无居左固定列
      let left_flg = false;
      //字段
      this.tableCols = result.tableShow.columnShow || []
      result.tableShow.columnShow.forEach(vo => {
        const column = {
          title: this.$locale(vo.colAlias || vo.colName),
          dataIndex: vo.colCode,
          mergeHeaderName: vo.mergeHeaderName,
        }
        if (vo.alignType) {
          column.align = vo.alignType
        }
        //宽度
        if (vo.colWidth) {
          column.minWidth = vo.colWidth
        } else if (vo.fixedWidth) {
          column.width = vo.fixedWidth
        }
        // 固定列
        if (vo.fixed && vo.fixed !== 'none') {
          column.fixed = vo.fixed
          if (vo.fixed === 'left') {
            left_flg = true;
          }
        }
        //是否可排序
        if (vo.isSort === 'Y') {
          column.sorter = true;
        }
        // 数据转换配置
        if (vo.dataConfig) {
          const dataConfig = JSON.parse(vo.dataConfig)
          if (dataConfig.type === 'image') {
            // 转换成图片
            column.slotDefault = 'image'
            column.showOverflow = false
          } else if (dataConfig.type === 'file') {
            // 转换成附件
            column.slotDefault = 'file'
            column.showOverflow = false
          } else if (dataConfig.type === 'links') {
            // 转换成超链接
            column.slotDefault = 'links'
          } else if (dataConfig.type === 'switch') {
            // 转换成开关
            column.slotDefault = 'switch'
          } else if (dataConfig.type === 'html') {
            // 转换成html
            column.slotDefault = 'html'
          }
        }

        this.columns.push(column)
      })

      // 行号居左
      if (left_flg) {
        this.columnLineNum.fixed = 'left'
        this.checkboxColumn.fixed = 'left'
        this.radioColumn.fixed = 'left'
      }

      this.initDictConfig()

      //是否分页
      if (result.tableShow.isPage === 'N') {
        this.pagination.show = false
      } else {
        //初始分页大小
        if (result.tableShow.pageNum && result.tableShow.pageNum > 0) {
          this.pagination.pageSize = result.tableShow.pageNum
        }
      }

      // 合并表头
      this.mergeHeader();

      //深拷贝
      let dealColumns = [];
      this.columns.map(item => {
        let newObj = Object.assign({}, item);
        newObj['visible'] = item.visible !== false
        dealColumns.push(newObj);
      });
      //原始列信息
      this.originalColumns = dealColumns

      // 插槽
      const customSlot = result.tableShow.customSlot ? JSON.parse(result.tableShow.customSlot) : {}
      if (customSlot.header) {
        this.header.componentFile = (resolve) => ({
          component: import(`@/views/` + customSlot.header + '.vue'),
          error: error,
          delay: 200,
          timeout: 10000
        })
        this.header.show = true
      }
      if (customSlot.footer) {
        this.footer.componentFile = (resolve) => ({
          component: import(`@/views/` + customSlot.footer + '.vue'),
          error: error,
          delay: 200,
          timeout: 10000
        })
        this.footer.show = true
      }

      //默认查询
      if (result.tableShow.isQuery === 'Y') {
        this.loadData()

        if (this.rows && this.rows.length > 0) {
          if (this.multi) {
            this.$refs.xTable.setCheckboxRow(this.rows, true)
          } else {
            this.$refs.xTable.setRadioRow(this.rows[0])
          }
        }
      }
    },
    mergeHeader() {
      //合并表头处理
      let mergeHeaderNameMap = new Map
      let columnIndex = 0
      let mergeCount = 0
      this.columns.forEach(item => {
          if (item.mergeHeaderName) {
            if (!mergeHeaderNameMap.has(item.mergeHeaderName)) {
              let mergeObj = {
                index: columnIndex + mergeCount,
                title: this.$locale(item.mergeHeaderName),
                children: []
              }
              mergeObj.children.push(item)
              mergeHeaderNameMap.set(item.mergeHeaderName, mergeObj)
              mergeCount++
            } else {
              mergeHeaderNameMap.get(item.mergeHeaderName).children.push(item)
            }
          }
          columnIndex++
        }
      )
      if (mergeHeaderNameMap.size > 0) {
        let newColumns = this.columns
        mergeHeaderNameMap.forEach(item => {
          newColumns.splice(item.index, 0, item)
        })
        this.columns = newColumns.filter(item => !(item.mergeHeaderName && item.mergeHeaderName.length > 0))
      }
    },
    async loadData(arg) {
      let url
      if (this.pagination.show) {
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.pagination.current = 1
        }
        url = this.url.queryViewListPage + '?viewCode=' + this.viewCode + '&pageNo=' + this.pagination.current + '&pageSize=' + this.pagination.pageSize
      } else {
        url = this.url.queryViewList + '?viewCode=' + this.viewCode
      }
      // 排序字段 升序or降序
      if (this.sorter && this.sorter.field && this.sorter.order) {
        url += "&sorterField=" + this.sorter.field
        url += "&sorterOrder=" + this.sorter.order
      }
      this.spinning++
      const queryValue = this.getQuery();
      //加载前事件
      if (this.tableShow.beforeScript) {
        const _that = this
        const func = handleCreateFunc(this.tableShow.beforeScript, this)
        const func_result = handleExecFunc(func, {url, arg, queryValue}, function () {
          _that.loadDataCallback(url, queryValue, arg);
        })
        if (!func_result) return;
      }
      this.loadDataCallback(url, queryValue, arg);
    },
    loadDataCallback(url, queryValue, arg) {
      postAction(url, queryValue).then((res) => {
        if (res.success) {
          if (this.pagination.show) {
            this.dataSource = res.result.records
            this.pagination.total = res.result.total
            this.pagination.current = res.result.current
          } else {
            this.dataSource = res.result
          }

          //加载后事件
          if (this.tableShow.afterScript) {
            const func = handleCreateFunc(this.tableShow.afterScript, this)
            handleExecFunc(func, {arg, queryValue, res})
          }
        } else {
          this.messageUtil.warning(res.message)
        }
      }).finally(() => {
        this.spinning--
      })
    },
    getQuery() {
      const queryValue = []
      this.queryColumns.forEach(query => {
        //时间范围查询
        if (query.queryDefaultValue && query.queryDefaultValue.startsWith('[') && query.queryDefaultValue.endsWith(']')) {
          const queryDefaultValueJson = JSON.parse(query.queryDefaultValue)
          if (queryDefaultValueJson.length === 2) {
            const item_start = {
              colCode: query.colCode,
              queryValue: queryDefaultValueJson[0]
            }
            const item_end = {
              colCode: query.colCode + '-end',
              queryValue: queryDefaultValueJson[1]
            }
            queryValue.push(item_start)
            queryValue.push(item_end)
          }
        } else if (query.queryDefaultValue) {
          const item = {
            colCode: query.colCode,
            queryValue: query.queryDefaultValue
          }
          queryValue.push(item)
        }
      })
      return {
        queryValue: queryValue,
        fks: this.fks,
        parameterValue: this.parameterValue
      }
    },
    //查询
    searchQuery() {
      this.loadData(1)
    },
    //重置
    searchReset() {
      this.queryColumns.forEach(vo => vo.queryDefaultValue = undefined)
      this.linkageMap = {}
      this.loadData(1)
    },
    //展开
    handleToggleSearch() {
      this.toggleSearchStatus = !this.toggleSearchStatus
    },
    initDictConfig() {
      let dictCodes = Object.keys(this.dictOptions).join(',')
      if (dictCodes && dictCodes.length > 0) {
        initDictOptionMap(dictCodes).then((res) => {
          if (res.success) {
            Object.keys(this.dictOptions).forEach(key => {
              this.$set(this.dictOptions, key, res.result[key])
            })
            //触发查询框重新加载
            this.dictOptionsFlg = this.dictOptionsFlg + 1
          }
        })
      }
    },
    changeQueryField(query, value) {
      if (query.showType && query.colCode) {
        this.linkageMap = {...this.linkageMap}
        this.linkageMap[query.colCode] = value;
      }
    },
    getCheckboxRecords() {
      if (this.multi) {
        const reserveRecords = this.$refs.xTable.getCheckboxReserveRecords()
        const records = this.$refs.xTable.getCheckboxRecords()
        return [...reserveRecords, ...records]
      } else {
        const row = this.$refs.xTable.getRadioRecord()
        const reserveRow = this.$refs.xTable.getRadioReserveRecord()
        if (row) {
          return [row]
        } else if (reserveRow) {
          return [reserveRow]
        } else {
          return []
        }
      }
    },
    async handlePageChange({currentPage, pageSize}) {
      this.pagination.current = currentPage
      this.pagination.pageSize = pageSize
      await this.loadData();
    },
    sortChangeEvent({column, property, order}) {
      this.sorter = {
        field: property,
        order: order,
      }
      this.loadData()
    },
    getRowStyle({row, rowIndex, $rowIndex}) {
      if (this.tableShow && this.tableShow.customRowFunc) {
        // 兼容历史数据升级
        const func = handleCreateFunc(this.tableShow.customRowFunc, this)
        const func_result = handleExecFunc(func, {row, rowIndex, $rowIndex, record: row})
        if (func_result && func_result['style']) {
          return func_result['style']
        }
        return func_result || {};
      }
      return {}
    },
    getCellStyle({row, rowIndex, $rowIndex, column, columnIndex, $columnIndex}) {
      if (this.tableShow && this.tableShow.customCellFunc) {
        const func = handleCreateFunc(this.tableShow.customCellFunc, this)
        const func_result = handleExecFunc(func, {row, rowIndex, $rowIndex, column, columnIndex, $columnIndex})
        return func_result || {};
      }
      return {}
    },
    mergeRowMethod({row, _rowIndex, column, visibleData}) {
      if (this.tableShow && this.tableShow.customSpanFunc) {
        const func = handleCreateFunc(this.tableShow.customSpanFunc, this)
        const func_result = handleExecFunc(func, {row, _rowIndex, column, visibleData})
        return func_result || {};
      }
      return {}
    },
    clickCellEvent({row, triggerRadio, triggerCheckbox, triggerTreeNode, triggerExpandNode}) {
      if (triggerCheckbox || triggerRadio || triggerTreeNode || triggerExpandNode) {
        return
      }
      if (this.multi) {
        this.$refs.xTable.setCheckboxRow(row, true)
      } else {
        this.$refs.xTable.setRadioRow(row)
        this.$emit('selected')
      }
    },
    seqMethod({row, rowIndex}) {
      return this.pagination.show ? ((this.pagination.current - 1) * this.pagination.pageSize + rowIndex + 1) : rowIndex + 1
    }
  }
}
</script>
<style lang="less" scoped>

</style>
